package me.goldze.mvvmhabit.utils;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegularUtils {
    private static Matcher matcher = null;
    private static Pattern pattern = null;

    public static String[] splitAll(String paramString)
    {
        if (pattern != null)
            return pattern.split(paramString);
        return new String[0];
    }

    public static String replaceAll(String paramString)
    {
        if (matcher != null)
            return matcher.replaceAll(paramString);
        return "";
    }

    public static void compile(String paramString, boolean paramBoolean1, boolean paramBoolean2)
    {
        if ((paramBoolean1) && (paramBoolean2))
            pattern = Pattern.compile(paramString, 10);
        do
        {
//            return;
            if ((!paramBoolean1) && (!paramBoolean2))
            {
                pattern = Pattern.compile(paramString);
                return;
            }
            if ((paramBoolean1) && (!paramBoolean2))
            {
                pattern = Pattern.compile(paramString, 2);
                return;
            }
        }
        while ((paramBoolean1) || (!paramBoolean2));
        pattern = Pattern.compile(paramString, 8);
    }

    public static boolean findNest()
    {
        if (matcher != null)
            return matcher.find();
        return false;
    }

    public static int matcherStart()
    {
        if (matcher != null)
            return matcher.start();
        return 0;
    }

    public static String group()
    {
        if (matcher != null)
            return matcher.group();
        return "";
    }

    public static int end()
    {
        if (matcher != null)
            return matcher.end();
        return 0;
    }

    public static int groupCount()
    {
        if (matcher != null)
            return matcher.groupCount();
        return 0;
    }

    public static String group(int paramInt)
    {
        if (matcher != null)
            return matcher.group(paramInt);
        return "";
    }

    public static void matcher(String paramString)
    {
        if (pattern != null)
            matcher = pattern.matcher(paramString);
    }

    public static String[] paramMatcher(String paramString1, String paramString2)
    {
        Matcher localMatcher = Pattern.compile(paramString2, 40).matcher(paramString1);
        ArrayList localArrayList = new ArrayList();
        while (localMatcher.find())
            localArrayList.add(localMatcher.group());
        return (String[])localArrayList.toArray(new String[localArrayList.size()]);
    }
}
